<#include "/_inc/_layout.ftl">
<#assign allowCreate=helper.isAuthorize("SystemUser.Create")/>
<#assign allowEdit=helper.isAuthorize("SystemUser.Edit")/>
<#assign allowDelete=helper.isAuthorize("SystemUser.Delete")/>
<#assign allowExport=helper.isAuthorize("SystemUser.Export")/>
<#assign allowRevisePassword=helper.isAuthorize("SystemUser.RevisePassword")/>
<#assign allowMapRole=helper.isAuthorize("SystemUser.MapRole")/>
<#assign allowAuthorize=helper.isAuthorize("SystemUser.Authorize")/>
<@header/>
<div id="gridtoolbar">
    <form id="gridform" class="jxform jxlayout-form form-inline">
        <div class="form-group">
            <input class="form-control w-200px" name="name" placeholder="账号/姓名/简拼关键字" autocomplete="off">
        </div>
        <select name="status" class="jxselect form-control" data-select-submit="true"
                data-allow-clear="false" data-width="110">
                <@html.statusEnableOptions/>
        </select>
        <button class="btn btn-primary ml-5" type="submit">
            <i class="fa fa-search"></i> 查询
        </button>
        <div class="btn-group">
            <@html.echo test=allowCreate>
                <a id="btn-create" class="btn btn-default">
                    <i class="icon-plus"></i> 新增
                </a>
            </@html.echo>
	        <@html.echo test=allowEdit>
	            <a id="btn-edit" class="btn btn-default">
                    <i class="icon-pencil"></i> 编辑
                </a>
            </@html.echo>
	        <@html.echo test=allowDelete>
	            <a id="btn-delete" class="btn btn-default">
                    <i class="icon-trash"></i> 删除
                </a>
            </@html.echo>
            <@html.echo test=allowRevisePassword>
                <a class="btn btn-default" data-target="#revise-passwordpopover" data-toggle="popover-x" data-placement="auto-bottom">
                    <i class="fa fa-key"></i> 重置密码
                </a>
            </@html.echo>
        </div>
        <div class="btn-group tool-mt">
            <@html.echo test=allowMapRole>
                <a id="btn-map-role" class="btn btn-default">
                    <i class="icon-users"></i> 用户角色
                </a>
            </@html.echo>
            <@html.echo test=allowAuthorize>
                <a id="btn-authorize" class="btn btn-default">
                    <i class="fa fa-gavel"></i> 用户授权
                </a>
            </@html.echo>
            <@html.echo test=allowExport>
	            <a id="btn-export" class="btn btn-default">
                    <i class="icon-share-alt"></i> 导出
                </a>
            </@html.echo>
        </div>
    </form>
</div>
<div id="gridcmenu">
    <@html.echo test=(allowEdit||allowDelete)>
        <ul class="dropdown-menu">
            <@html.echo test=allowEdit><li><a id="btn-cmedit"><i class="icon-pencil"></i> 编辑</a></li></@html.echo>
            <@html.echo test=allowDelete><li><a id="btn-cmdelete"><i class="icon-trash"></i> 删除</a></li></@html.echo>
        </ul>
    </@html.echo>
</div>
<div id="revise-passwordpopover" class="popover popover-x popover-default popover-lg">
    <div class="arrow"></div>
    <form id="revise-passwordform" class="jxform form-horizontal"
          action="<@html.url "/auth/user/revise-password"/>"
          data-layout="bootstrap" data-protip="false" method="post">
        <input id="revise-ids" name="userIds" type="hidden" />
        <div class="popover-title">
            <span class="close" data-dismiss="popover-x">&times;</span>重置密码
        </div>
        <div class="popover-content">
            <div class="form-group">
                <label class="col-md-3 control-label">新密码：</label>
                <div class="col-md-8">
                    <input id="revise_from_password" name="password" class="form-control" type="password" autocomplete="off"
                           data-validate="required: [true,'请输入新密码']">
                </div>
            </div>
            <div class="form-group">
                <label class="col-md-3 control-label">确认密码：</label>
                <div class="col-md-8">
                    <input name="confirm_password" class="form-control" type="password" autocomplete="off"
                           data-validate="required: [true,'请输入确认密码'],equalTo: ['#revise_from_password','确认密码必须与新密码输入一致']">
                </div>
            </div>
        </div>
        <div class="popover-footer">
            <button class="btn btn-primary" type="submit">
                <i class="fa fa-save"></i> 保存
            </button>
        </div>
    </form>
</div>
<table id="grid" class="jxgrid" title="<i class='jxfs'></i> 系统用户"
       data-options="form: '#gridform',toolbar: '#gridtoolbar',queryParams:{status:1}"
       data-dialog-width="40%" data-dialog-height="620px">
    <thead>
        <tr>
            <th data-options="field: 'ck',checkbox:true"></th>
            <th data-options="title: '姓名', field: 'name', width: 100, align: 'center',sortable: true"></th>
            <th data-options="title: '账号', field: 'account', width: 150, sortable: true, align: 'center'"></th>
            <th data-options="title: '部门', field: 'departmentName', width: 150, align: 'center'"></th>
            <th data-options="title: '状态', field: 'status', width: 50, align: 'center',formatter:jx.gf.status"></th>
            <th data-options="title: '登录次数', field: 'loginCount', width: 100, align: 'center'"></th>
            <th data-options="title: '首次登录时间', field: 'firstVisit', width: 170, align: 'center'"></th>
            <th data-options="title: '最后登录时间', field: 'lastVisit', width: 170, align: 'center'"></th>
            <th data-options="title: '操作人',field:'operateUserName',width:100,align:'center'"></th>
            <th data-options="title: '操作时间',field:'operateDateTime',width:170,align:'center',sortable: true"></th>
            <th data-options="title: '备注',field:'remark',width:250"></th>
        </tr>
    </thead>
</table>
<@footer>
    <script src="<@html.url '/auth/js/user.js'/>"></script>
</@footer>
